<?php
#注册插件
RegisterPlugin("txgonggao","ActivePlugin_txgonggao");

function ActivePlugin_txgonggao() {
	Add_Filter_Plugin('Filter_Plugin_Zbp_MakeTemplatetags','txgonggao_Zbp_MakeTemplatetags');
}

function txgonggao_Zbp_MakeTemplatetags() {
	global $zbp;

	$config = array(
		"bt" => $zbp->Config('txgonggao')->bt,
		"nr" => $zbp->Config('txgonggao')->nr,
		"bk" => $zbp->Config('txgonggao')->bk,
		"bg" => $zbp->Config('txgonggao')->bg,
		"kd" => $zbp->Config('txgonggao')->kd,
	);

	$zbp->header .=  '<link rel="stylesheet" type="text/css" href="'.$zbp->host.'zb_users/plugin/txgonggao/style/txcstx.css"/>' . "\r\n";
	$zbp->header .=  '<style type="text/css">.float_layer{width:' . $config["kd"] . 'px;border:1px solid #' . $config["bk"] . ';}.float_layer h2{border-bottom:1px solid #' . $config["bk"] . '; background-color:#' . $config["bg"] . ';}</style>' . "\r\n";
	$zbp->footer .=  '<script language="javascript" src="'.$zbp->host.'zb_users/plugin/txgonggao/js/txgonggao.js"></script>' . "\r\n";
	$zbp->footer .=  '<div class="float_layer" id="float_layer">
    <h2>
        <strong>' . $config["bt"] . '</strong>
        <a id="btn_min" href="javascript:;" class="min"></a>
        <a id="btn_close" href="javascript:;" class="close"></a>
    </h2>
    <div class="content">
    	<div class="wrap">' . $config["nr"] . '</div>
     </div>
</div>' . "\r\n";

}

function InstallPlugin_txgonggao() {
    global $zbp,$obj,$bucket;
    //配置初始化
    if (!$zbp->Config('txgonggao')->HasKey('version')) {
        $zbp->Config('txgonggao')->version = '1.0';
        $zbp->Config('txgonggao')->bt = '标题';
		$zbp->Config('txgonggao')->nr = '公告内容，请自行在插件管理界面输入。公告内容，请自行在插件管理界面输入。公告内容，请自行在插件管理界面输入。公告内容，请自行在插件管理界面输入。公告内容，请自行在插件管理界面输入。';
		$zbp->Config('txgonggao')->bk = 'ddd';
		$zbp->Config('txgonggao')->bg = 'f1f1f1';
		$zbp->Config('txgonggao')->kd = '300';
        $zbp->SaveConfig('txgonggao');
    }

}

function UninstallPlugin_txgonggao() {
	global $zbp;
//	$zbp->DelConfig('txgonggao');
}